<!DOCTYPE html>
<html>
<head>
<title>编辑管理员</title>
#include("../include/common.html")
</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>编辑管理员</h5>
            </div>
           <form id="inputForm" action="update" method="post">
                <input type="hidden" name="id" value="#(admin.id)">
                <div class="ibox-content">
                    <div class="form-horizontal clearfix">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">用户名：</label>
                            <div class="col-sm-3">
                                #(admin.username)
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">密码：</label>
                            <div class="col-sm-3">
                                <input id="password" class="form-control" type="password" name="password" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">确认密码：</label>
                            <div class="col-sm-3">
                                <input class="form-control" type="password" name="rePassword" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">备注：</label>
                            <div class="col-sm-3">
                                <input class="form-control" type="text" name="name" value="#(admin.name)">
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>如：编辑</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">超级管理员：</label>
                            <div class="col-sm-3">
                                <div class="radio">
                                    <label class="m-r"><input name="type" value="1" type="radio" #if(admin.type==1) checked #end>是</label>
                                    <label class="m-r"><input name="type" value="0" type="radio" #if(admin.type==0) checked #end>否</label>
                                </div>
                                <span class="help-block m-b-none"><i class="fa fa-info-circle"></i>超级管理员不受权限所控制</span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">权限：</label>
                            <div class="col-sm-8">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label" style="width: 110px"><a href="javascript:;" class="selectAll" title="全选此组权限">模型管理：</a></label>
                                    <div class="col-sm-6">
                                         <div class="checkbox">
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/model" #if(admin.permissions.contains("/admin/model")) checked #end/>模型管理
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label" style="width: 110px"><a href="javascript:;" class="selectAll" title="全选此组权限">栏目管理：</a></label>
                                    <div class="col-sm-6">
                                         <div class="checkbox">
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/category" #if(admin.permissions.contains("/admin/category")) checked #end/>栏目管理
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label" style="width: 110px"><a href="javascript:;" class="selectAll" title="全选此组权限">内容管理：</a></label>
                                    <div class="col-sm-6">
                                         <div class="checkbox">
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/content" #if(admin.permissions.contains("/admin/content")) checked #end/>内容管理
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label" style="width: 110px"><a href="javascript:;" class="selectAll" title="全选此组权限">表单管理：</a></label>
                                    <div class="col-sm-6">
                                         <div class="checkbox">
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/form" #if(admin.permissions.contains("/admin/form")) checked #end/>表单管理
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label" style="width: 110px"><a href="javascript:;" class="selectAll" title="全选此组权限">自定义表管理：</a></label>
                                    <div class="col-sm-6">
                                         <div class="checkbox">
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/table" #if(admin.permissions.contains("/admin/table")) checked #end/>自定义表管理
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label" style="width: 110px"><a href="javascript:;" class="selectAll" title="全选此组权限">营销管理：</a></label>
                                    <div class="col-sm-6">
                                         <div class="checkbox">
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/ad" #if(admin.permissions.contains("/admin/ad")) checked #end/>广告
                                            </label>
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/ad_position" #if(admin.permissions.contains("/admin/ad_position")) checked #end/>广告位
                                            </label>
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/friend_link" #if(admin.permissions.contains("/admin/friend_link")) checked #end/>友情链接
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label" style="width: 110px;"><a href="javascript:;" class="selectAll" title="全选此组权限">系统管理：</a></label>
                                    <div class="col-sm-6">
                                         <div class="checkbox">
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/role" #if(admin.permissions.contains("/admin/role")) checked #end/>角色
                                            </label>
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/admin" #if(admin.permissions.contains("/admin/admin")) checked #end/>管理员
                                            </label>
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/config" #if(admin.permissions.contains("/admin/config")) checked #end/>系统配置
                                            </label>
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/template" #if(admin.permissions.contains("/admin/template")) checked #end/>模板
                                            </label>
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/cache" #if(admin.permissions.contains("/admin/cache")) checked #end/>清除缓存
                                            </label>
                                            <label class="m-r">
                                                <input class="checkbox" type="checkbox" name="permissions" value="/admin/profile" #if(admin.permissions.contains("/admin/profile")) checked #end/>账号设置
                                            </label>
                                        </div>
                                    </div>
                                 </div>
                            </div>
                        </div>
                    </div>
	                #if(admin.isSystem)
	                <div class="form-group">
	                    <label class="col-sm-3 control-label">&nbsp;</label>
	                    <div class="col-sm-8">
	                       <h4 class="text-danger">系统内置管理员不允许修改</h4>
	                    </div>
	                </div>
	                #end
                </div>
                <div class="modal-footer col-sm-3 col-sm-offset-2">
                    <button type="submit" class="btn btn-w-m btn-primary" #if(admin.isSystem) disabled="disabled" #end>确定</button>
                    <button type="button" class="btn btn-w-m btn-default" onclick="history.back(); return false;">取消</button>
                </div>
            </form>
        </div>
    </div>
</body>
</html>
<script type="text/javascript">
$().ready(function() {

    var $inputForm = $("#inputForm");
    var $selectAll = $("#inputForm .selectAll");
    
    
    
    $selectAll.click(function() {
        var $this = $(this);
        var $thisCheckbox = $this.closest("div").find("input:checkbox");
        if ($thisCheckbox.filter(":checked").size() > 0) {
            $thisCheckbox.prop("checked", false);
        } else {
            $thisCheckbox.prop("checked", true);
        }
        return false;
    });
    
    
    // 表单验证
    $inputForm.validate({
        rules: {
            password: {
                minlength: 4
            },
            rePassword: {
                equalTo: "#password"
            },
            type:"required"
        }
    });

});
</script>